home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Atari Compendium
/
The Atari Compendium (Toad Computers) (1994).iso
/
files
/
umich
/
utils
/
encrypt.arc
/
ENCRYPT.C
next >
Wrap
C/C++ Source or Header
|
1988-04-26
|
2KB
|
64 lines
/* ENCRYPTOR */
/* Compute!'s Atari ST Disk & Magazine */
/* October 1986 -- Volume 1, No. 1 */
/* = 1986 Compute Publications/ABC */
#include <stdio.h>
#include <osbind.h>
main()
{
int i = 0, c1;
char password[40], filename[40], c;
FILE *fopen (), *file_ptr1, *file_ptr2;
printf ( "What is the name of the file to be CRYPTed? " );
scanf ( "%s", filename ); printf ( "\n" );
printf ( "What is the PASSWORD to be used? ");
scanf ( "%s", password ); printf ( "\n" );
file_ptr1 = fopen ( filename, "r" );
if ( file_ptr1 == NULL)
{
printf ( "Couldn't open %s for input.\n", filename );
getchar();
}
else
{
file_ptr2 = fopen ( "qqqq", "w" );
if ( file_ptr2 == NULL )
{
printf ( "Couldn't open output file.\n" );
getchar();
}
else
{
while ( ( c = fgetc ( file_ptr1 ) ) != EOF )
{
c1 = password[i] * 2 - c;
if ( c1 > 255 )
c1 -= 256;
if ( c1 < 0 )
c1 += 256;
fputc ( c1, file_ptr2 );
++i;
if ( password[i] == '\0' )
i = 0;
}
fclose ( file_ptr1 );
fclose ( file_ptr2 );
Fdelete ( filename );
Frename ( 0,"qqqq", filename );
}
}
}